package com.grapevine.contact;

import com.grapevine.contact.config.ConfigKey;
import com.grapevine.contact.config.SharePrefareManager;

import android.app.TabActivity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.widget.TabHost;

public class GrapVineContact extends TabActivity
{
//	private static final int DIAL_HISTORY_MODE = 1;
	private static final int CONTACT_MODE = 2;
//	private static final String CALL_LOG_TYPE = "vnd.android.cursor.dir/calls";

//	private TabHost mTabHost;

	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		TabHost mTabHost = getTabHost();

		mTabHost.addTab(mTabHost.newTabSpec("dialer").setIndicator("拨号盘",
				getResources().getDrawable(R.drawable.ic_tab_dialer)).setContent(new Intent(this, DialActivity.class)));

		mTabHost.addTab(mTabHost.newTabSpec("contact_log").setIndicator("通话记录",
				getResources().getDrawable(R.drawable.ic_tab_recent)).setContent(
				new Intent(this, CallLogActivity.class)));

		mTabHost.addTab(mTabHost.newTabSpec("contacts").setIndicator("联系人",
				getResources().getDrawable(R.drawable.ic_tab_contacts)).setContent(new Intent(this, Contact.class)));

		mTabHost.addTab(mTabHost.newTabSpec("control").setIndicator("葡萄藤",
				getResources().getDrawable(R.drawable.ic_tab_starred)).setContent(new Intent(this, Control.class)));
		
		SharedPreferences sharedPreferences = SharePrefareManager.getSharedPreferences(this);
		int postion = sharedPreferences.getInt(ConfigKey.CURRENT_ACTIVITY, CONTACT_MODE);
		
		mTabHost.setCurrentTab(postion);
		//		setCurrentTab(getIntent());
	}
	
	@Override
	protected void onDestroy()
	{
//		
		super.onDestroy();
		android.os.Process.killProcess(android.os.Process.myPid());
	}
	
//	private void setCurrentTab(Intent intent)
//	{
//		Activity activity = getLocalActivityManager().getActivity(mTabHost.getCurrentTabTag());
//		if (activity != null)
//		{
//			activity.closeOptionsMenu();
//		}
//		if (CALL_LOG_TYPE.equals(intent.getType()))
//		{
//			mTabHost.setCurrentTab(DIAL_HISTORY_MODE);
//		}
//		else
//		{
//			mTabHost.setCurrentTab(CONTACT_MODE);
//		}
//	}

}